<?php
    namespace app\admin\controller;
    use think\Controller;

    class Admin extends Controller{
        public function add(){
            //判断是否是post提交
            if(request()->isPost()){
                //获取提交数据
                $data=input('post.');
                //validate
                $validate = validate('AdminUser');
                if(!$validate->check($data)){
                    $this->error($validate->getError());
                }
                $data['satus']=1;
                $id='';
                try{
                    $id=model('AdminUser')->add($data);
                }catch(\Exception $e){
                    echo $e->getMessage();
                }

                if($id){
                    $this->success('id='.$id.'用户新增成功');
                }

            }else{
                return $this->fetch();
            }
            
        }
    }